<?php

require "./lib/src/skey.php";

$uploads_url = base_url('uploads');
$partner_url = base_url('partner');
$kirim_url = base_url('partnership');

$menu = $this->uri->segment(3, "");
$mapdir = "<a href='$partner_url/' class='taut'>Home </a> &gt;";

switch($menu)
{
	case "baru":
		$mapdir .= "
			<a href='$partner_url/acara' class='taut'>Acara</a>
			&gt; 
			<b>Buat Acara Baru</b>
		";
		
		$cekbatasacara = $this->partnermodel->get_batas_acara($uid);
		if($cekbatasacara !== TRUE)
		{
			$isipage = "
				<div id='content2'>
						<h3>Tambah Acara Baru</h3>
						<div class='isicontent2'>
							Anda masih memiliki 5 acara yang belum lewat/berakhir. <br />
							Anda hanya dapat membuat 5 acara yang akan dilaksanakan!
						</div>
				</div>
				";
		}
		else
		{
			$isipage = "
						
					<div id='content2'>
							<h3>Tambah Acara Baru</h3>
							<div class='isicontent2'>
								 
								  <p>
									<b>Perhatian!</b> Acara adalah tanggung jawab setiap pengguna/user yang sedang aktif(login).
								  </p>
								  <br />
							</div>
							
								<div class='isicontent2'>
								
								  <form id='FrmMasukan' action='$kirim_url/acarabaru' method='post' onsubmit='return validasi_acara(this)'  enctype='multipart/form-data'  >
									
										<table>
											<tbody>
												<tr>
													<td class='left'>Nama *  </td>
													<td class='right'><input name='nama' type='text' placeholder='Acara' /></td>
												</tr>
												<tr>
													<td class='left'>Deskripsi Acara *  </td>
													<td class='right'><textarea id='deskripsi' name='deskripsi' placeholder='deskripsi' cols='30' rows='5'>Deskripsi Acara</textarea></td>
												</tr>
												<tr>
													<td class='left'>Lokasi Acara *  </td>
													<td class='right'><input name='lokasi' type='text' placeholder='Lokasi Acara' />
													<br /><div class='note'><a href='#'>Tips penulisan lokasi</a> : kota, kabupaten, provinsi</div>
													</td>
												</tr>
												<tr>
													<td class='left'>Waktu Pelaksanaan * </td>
													<td class='right'><input name='tanggal' type='text' id='tglacara' />
														<div class='note'>format : yyyy-mm-dd</div>
													</td>
												</tr>
												<tr>
													<td class='left'>Gambar  </td>
													<td class='right'><input name='gambar' type='file' />
													<br /><div class='keterangan'>Anda juga dapat menambahkan gambar untuk acara.</div></td>
												</tr>
												
												<tr>
													<td class='left'>&nbsp;</td>
													<td class='right'>Tanda Bintang (*) berarti Kolom wajib Diisi</td>
												</tr>
												<tr>
													<td class='left'> &nbsp; </td>
													<td class='right'>
													<input type='submit' value='Tambah'> &nbsp; <input type='reset' value='Ulang'></td>
												</tr>
											
											</tbody>
										</table>
										
								  </form>
								</div>
								
							</div>
				";
			}
		
	;
	break;
	
	case "edit":
		$mapdir .= "
			<a href='$partner_url/acara' class='taut'>Acara</a>
			&gt; 
			<b>Edit Acara</b>
		";
		
		$ida = $this->input->get('ida');
		$hasil = $this->partnermodel->get_data_acara($ida,$uid);
		
		if($hasil !== FALSE)
		{
			foreach($hasil AS $hasil2){
				$ida = $hasil2->idacara;
				$nama = html_escape($hasil2->nama);
				$lokasi = html_escape($hasil2->lokasi);
				$gambar = $hasil2->gambar;
				
				
				$tampil = "
							<tr>
								<td class='left'>Nama Acara * </td>
								<td class='right'><input name='nama' type='text' value='$nama' /></td>
							</tr>
							<tr>
								<td class='left'>Deskripsi Acara * </td>
								<td class='right'><textarea id='deskripsi' name='deskripsi' cols='30' rows='5'>$hasil2->deskripsi</textarea></td>
							</tr>
							<tr>
								<td class='left'>Lokasi Acara * </td>
								<td class='right'>
								<input name='lokasi' type='text' value='$lokasi' />
								<br /><div class='note'><a href='#'>Tips penulisan lokasi</a> : kota, kabupaten, provinsi</div>
								</td>
							</tr>
							<tr>
								<td class='left'>Tanggal Acara * </td>
								<td class='right'><input name='tanggal' type='text' id='tglacara' value='$hasil2->tanggal' />
									<div class='note'>format : yyyy-mm-dd</div>
								</td>
							</tr>
							<tr>
								<td class='left'>Gambar : </td>
								<td class='right'><input name='gambar' type='file' />
								<br /><div class='keterangan'>Anda juga dapat mengubah Gambar (kosongkan jika tidak akan diubah).</div></td>
							</tr>
						
							<tr>
								<td class='left'>&nbsp;</td>
								<td class='right'>Tanda Bintang (*) berarti Kolom wajib Diisi</td>
							</tr>
							<tr>
								<td class='left'> &nbsp; </td>
								<td class='right'><input type='hidden' name='ida' value='$ida' /><input type='hidden' name='oldgambar' value='$gambar' />
								<input type='submit' value='Ubah'> &nbsp; <input type='reset' value='Ulang'></td>
							</tr>";
			}
		}else{
			$tampil = "<tr>
							<td class='left'>&nbsp;</td>
							<td class='right'>Data Tidak Ditemukan</td>
						</tr>";
		}
		
		$isipage = "
				<div id='content2'>
						<h3>Edit Acara</h3>
							<div class='isicontent2'>
							
							  <form id='FrmMasukan' action='$kirim_url/updateacara' method='post' enctype='multipart/form-data' >
								
									<table>
										<tbody>
											$tampil
										
										</tbody>
									</table>
									
							  </form>
							</div>
							
						</div>
			";
	;
	break;
	
	
	case "detail":
		$mapdir .= "
			<a href='$partner_url/acara'>Acara</a>
			&gt; 
			<b>Detail</b>
		";
		
		$ida = $this->input->get('ida');
		$hasil = $this->partnermodel->get_data_acara($ida, $uid);
		
		if($hasil !== FALSE)
		{
			foreach($hasil AS $hasil2)
			{
				$hariini = date("Y-m-d");
				$nama = html_escape($hasil2->nama);
				$deskripsi = auto_link(xss_clean($hasil2->deskripsi));
				$lokasi = html_escape($hasil2->lokasi);
				$tgl = strtotime($hasil2->tanggal);
				$tanggal = date("d m Y", $tgl);
				$jam = date("H.i",$tgl);
				$gambar = "";
				$status = "";
				
				if( ! empty($hasil2->gambar)){
					$gambar = "<a id='lihat' href='$uploads_url/acara/$hasil2->gambar'><img alt='Gambar Acara' src='$uploads_url/acara/$hasil2->gambar' class='preview' /></a>";
				}
				
				if($tanggal < $hariini)
				{
					$status = "(<b>Telah Berakhir</b>)";
				}
				
				$tampil = "<tr>
								<td class='left'>Nama Acara </td>
								<td class='right'> 
									$nama $status 
									<a href='$admin_url/acara/edit?ida=$ida' class='taut'>Edit</a> &nbsp; 
									<a href='$kirim_url/hapusacara?ida=$ida' onclick='return konfirmhapus()' title='Hapus Acara'>Hapus</a>
								</td>
							</tr>
							
							<tr>
								<td class='left'>Waktu Pelaksanaan </td>
								<td class='right'>$tanggal  jam $jam</td>
							</tr>
							<tr>
								<td class='left'>Lokasi </td>
								<td class='right'>$lokasi</td>
							</tr>
							
							<tr>
								<td class='left'>Deskripsi Acara </td>
								<td class='right'>$deskripsi</td>
							</tr>
							<tr>
								<td class='left'>Gambar/Brosur </td>
								<td class='right'>$gambar</td>
							</tr>
							
							<tr>
								<td class='left'>&nbsp;</td>
								<td class='right'>&nbsp;</td>
							</tr>
							<tr>
								<td class='left'> &nbsp; </td>
								<td class='right'><a href='$partner_url/acara' class='taut'>&lt;&lt; Kembali</a></td>
							</tr>";
			}
		}else{
			$tampil = "<tr>
							<td class='left'>&nbsp;</td>
							<td class='right'>Data Tidak Ditemukan</td>
						</tr>";
		}
		
		$isipage = "
				<div id='content2'>
						<h3>Detail Acara</h3>
							<div class='isicontent2'>
							
								<table>
									<tbody>
									
										$tampil
									
									</tbody>
								</table>
									
							</div>
							
						</div>
			";
	;
	break;
	
	default:
		$mapdir .= "
			<b>Acara</b>
		";
		
		$acara = $this->partnermodel->get_daftar_acara($uid);
		$dataacara = "";
		
		if($acara !== FALSE)
		{
			foreach($acara AS $data)
			{
				$ida = $data->idacara;
				$nama = html_escape($data->nama);
				
				
				$dataacara .= "
				<tr>
					<td class='left'>
						$nama 
					</td>
					<td class='right'> 
						<a href='$partner_url/acara/detail?ida=$ida'>Detail</a> &nbsp;
						<a href='$partner_url/acara/edit?ida=$ida' class='taut'>Edit</a> &nbsp; 
						<a href='$kirim_url/hapusacara?ida=$ida' onclick='return konfirmhapus()' title='Hapus Acara'>Hapus</a>
					</td>
				</tr>
				<tr>
					<td class='left'>&nbsp;</td>
					<td class='right'>&nbsp;</td>
				</tr>
				";
			}
		}else{
			$dataacara = "
			<tr>
			<td class='left'>&nbsp;</td>
			<td class='right'>Belum ada data Acara. <a href='$partner_url/acara/baru' class='taut'>Buat Acara?</a>
			</td>
			</tr>";
		}
		
		$isipage = "
				<div id='content2'>
						<h3>Daftar Acara</h3>
							<div class='isicontent2'>
							 <table>
								<tbody>
									<tr><td class='left'><a href='$partner_url/acara/baru' class='taut'>Tambah Baru</a></td><td class='right'>&nbsp;</td></tr>
									<tr><td class='left'>&nbsp;</td><td class='right'>&nbsp;</td></tr>
									$dataacara
									<tr><td class='left'>&nbsp;</td><td class='right'>&nbsp;</td></tr>
									<tr><td class='left'><a href='$partner_url/acara/baru' class='taut'>Tambah Baru</a></td></tr>
								</tbody>
							 </table>
							</div>
							
					</div>
			";
	;
	break;
}


$data['isi_page'] = $isipage;
$data['site_title'] = 'Event - Dadan Network';
$data['base_url'] = base_url();
$data['map_dir'] = $mapdir;
$data['tahun_sekarang'] = date("Y");

$this->parser->parse('template/partner', $data);


/* End of file acara.php */
/* Location: ./application/views/partner/acara.php */
